﻿@model IEnumerable<MVC.Models.Book>

<h2>@ViewBag.Title</h2>

<h3>@ViewBag.Message</h3>

<table class="table">
    <tr>
        <th id="titleCol">
            @Html.DisplayNameFor(model => model.Title)
        </th>
        <th id="authorCol">
            @Html.DisplayNameFor(model => model.Author)
        </th>
        <th id="genreCol">
            @Html.DisplayNameFor(model => model.Genre)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td title="@item.Title by @item.Author 
                @item.Description">
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td title="@item.Title by @item.Author
                @item.Description ">
                @Html.DisplayFor(modelItem => item.Author)
            </td>
            <td title="@item.Title by @item.Author
                @item.Description ">
                @Html.DisplayFor(modelItem => item.Genre)
            </td>
            <td>
                @Html.ActionLink("Details", "Details", new { id = item.BookId }) | 
                @Html.ActionLink("Add to My List", "AddToList", new { id = item.BookId })
                @if (User.Identity.Name.Equals(item.Creator))
                {
                    <span> | </span>
                    @Html.ActionLink("Edit", "Edit", new { id = item.BookId })
                }
            </td>
        </tr>
    }

</table>
